#ifndef _glpane_
#define _glpane_

#include "wx/wx.h"
#include "wx/glcanvas.h"
#include "../Mesh.h"

class GLPane : public wxGLCanvas
{

public:
	GLPane(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style=0, const wxString& name=_T("GLCanvas"), int* attribList = 0);

	void resized(wxSizeEvent& evt);

	int getWidth();
	int getHeight();

	void render(wxPaintEvent& evt);

	//void addScene(Printable *scene){this->scene = scene;}

	void prepare3DViewport(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y);

	void setColor(float R, float G, float B);

	void setMesh(Mesh* mesh);
	void showGrid(bool);

	// events
	void mouseMotion(wxMouseEvent& event);
	void mouseDown(wxMouseEvent& event);
	void mouseWheelMoved(wxMouseEvent& event);
	void mouseReleased(wxMouseEvent& event);
	void rightClick(wxMouseEvent& event);
	void mouseLeftWindow(wxMouseEvent& event);
	void keyPressed(wxKeyEvent& event);
	//void keyReleased(wxKeyEvent& event);
	void onSize( wxSizeEvent& event );

	DECLARE_EVENT_TABLE()

private:
    int spinning, moving;
    int beginx, beginy;
    float curquat[4];
    float lastquat[4];

    bool show_grid;

    float zoom_fat;
    float observer_pos[3];

    Mesh *mesh;
};

#endif
